package com.coolwen.service;

import com.coolwen.dao.MemberMapper;
import com.coolwen.entity.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 松红 on 2016/12/5.
 */
@Service("memberService")
public class MemberServiceImpl implements MemberService {
    @Autowired
    MemberMapper memberMapper;

    /**
     * 通过球员id获取单个球员信息
     *
     * @param memberId
     * @return
     */
    @Override
    public Member findMemberById(Integer memberId) {
        return memberMapper.selectByPrimaryKey(memberId);
    }

    /**
     * 通过球队id查找所有球员信息
     *
     * @param teamId
     * @return
     */
    @Override
    public  List<Member> findMembersByTeamId(Integer teamId) {
        return memberMapper.selectByTeamId(teamId);
    }

    /**
     * 通过球员id删除球员
     *
     * @param memberId
     * @return
     */
    @Override
    public int deleteMemberById(Integer memberId) {
        return memberMapper.deleteByPrimaryKey(memberId);
    }

    /**
     * 添加球员信息
     *
     * @param member
     * @return
     */
    @Override
    public int addmember(Member member) {
        return memberMapper.insertSelective(member);
    }

    /**
     * 修改队员
     * @param member
     * @return
     */
    @Override
    public int updatemember(Member member) {
        return memberMapper.updateByPrimaryKeySelective(member);
    }

    /**
     * 更新成员
     *
     * @param integer
     * @return
     */
    @Override
    public int insertTeamId(Integer integer) {
        return memberMapper.insertTeamId(integer);
    }



}
